<?php
class DB {
    private static $objInstance;
    public static function getInstance()
    {
        if(!self::$objInstance)
        {

            #self::$objInstance = new PDO('mysql:host=localhost;dbname=ruicosta_mvc', 'ruicosta_ruicost', 'p@ssw0rd');
            #self::$objInstance = new PDO('pgsql:host=localhost;dbname=goa_waypos', 'developer', 'devteam');
            self::$objInstance = new PDO('mysql:host=localhost;dbname=coisas', 'root', 'root');

	    self::$objInstance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        }
        return self::$objInstance;
    }
}


class Database
{
    protected $dbh = null;

    public function getDbh()
    {
        return DB::getInstance();
    }

}



class Record implements ArrayAccess
{
	public $data = array();
	public function __construct()
	{
	}

	public function offsetSet($offset, $value) {
		if (is_null($offset)) {
			$this->data[] = $value;
		} else {
			$this->data[$offset] = $value;
		}
	}

	public function offsetExists($offset) {
		return isset($this->data[$offset]);
	}

	public function offsetUnset($offset) {
		unset($this->data[$offset]);
	}

	public function offsetGet($offset) {
		return isset($this->data[$offset]) ? $this->data[$offset] : null;
	}

	var $default = array();

	public function save()
	{
	}
	public function delete()
	{
	}
}

?>